﻿<UserControl x:Class="ResourceEnumerator.UI.EnumeratorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:inrastructure="clr-namespace:ResourceEnumerator.Inrastructure"
             xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.14.0">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ComboBoxStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Background="{DynamicResource {x:Static vsfx:VsBrushes.CommandShelfBackgroundGradientKey}}" 
            BorderThickness="1" BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBorderKey}}"
            Cursor="Arrow">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
                       Text="Select a Resource" Margin="2 1"
                       Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}"/>

            <ComboBox Grid.Column="1" Grid.Row="1"
                      MinWidth="300" MaxWidth="300"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Center"
                      Margin="1"
                      BorderThickness="1.2"
                      ItemsSource="{Binding EnumeratedResources}"
                      SelectedItem="{Binding SelectedResource}">
                <ComboBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type inrastructure:ResourceItem}">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Key}" Margin="5 0" FontWeight="Bold" />
                            <TextBlock Text="{Binding ElementType}" FontStyle="Italic" Opacity="0.7"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>

            <Button MaxHeight="14" MaxWidth="16"
                        Grid.Column="1" Grid.Row="0"
                        FontWeight="Light"
                        Margin="1"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        HorizontalContentAlignment="Center"
                        VerticalContentAlignment="Center"
                        ToolTip="Close"
                        ToolTipService.ShowOnDisabled="False"
                        Command="{Binding CloseCommand}"
                        Visibility="Collapsed">
                <Button.Template>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="ButtonBorder" Height="14" Width="14" CornerRadius="1" Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition To="Pressed" GeneratedDuration="0:0:0.2" />
                                        <VisualTransition To="MouseOver" GeneratedDuration="0:0:0.2" />
                                        <VisualTransition From="Pressed" To="MouseOver" GeneratedDuration="0:0:0.2" />
                                        <VisualTransition From="MouseOver" To="Normal" GeneratedDuration="0:0:0.4" />
                                        <VisualTransition From="Normal" To="Disabled" GeneratedDuration="0:0:0.2" />
                                        <VisualTransition From="Disabled" To="Normal" GeneratedDuration="0:0:0.1" />
                                    </VisualStateGroup.Transitions>
                                    <VisualStateGroup.States>
                                        <VisualState x:Name="Normal" />
                                        <VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="ButtonBorder"
                                                                Storyboard.TargetProperty="Background.Color"
                                                                To="HotPink" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="ButtonBorder"
                                                                Storyboard.TargetProperty="Background.Color"
                                                                To="Red" />
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <ColorAnimation Storyboard.TargetName="ButtonBorder"
                                                                Storyboard.TargetProperty="Background.Color"
                                                                To="LightGray" />
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup.States>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <TextBlock Text="X" Name="TextBlockX"
                                       MinWidth="13" MaxWidth="13"
                                       Foreground="Black"
                                       TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Cursor" Value="Arrow" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>
            </Button>
        </Grid>
    </Border>
</UserControl>
